/*
day240
2020.4.24
*/
#include<iostream>
#include<vector>
using namespace std;
struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
public:
    TreeNode* insertIntoMaxTree(TreeNode* root, int val) {
		TreeNode *pre=new TreeNode(0);
		pre->right=root;
		help(pre,val);
		return pre->right;
    }
    
    void help(TreeNode *pre,const int &val)
    {
    	if(!pre->right)
    	{
    		pre->right=new TreeNode(val); 
    		return ;
		}
		
		if(pre->right->val<val)
		{
			TreeNode *tem=new TreeNode(val);
			tem->left=pre->right; 
			pre->right=tem;
			return ;
		}
		
		help(pre->right,val);
	}
};


int main()
{
	return 0;
}
